package com.stone.design.patterns.prototype;

import android.util.Log;

import java.util.ArrayList;
import java.util.List;

import static com.stone.design.patterns.factory.Tag.TAG;

/**
 * @description
 * @Time 2018/4/3 9:28
 * Created by Stone on 2018/4/3.
 */

public class WordDocument implements Cloneable {

    private String mText;
    private ArrayList<String> images = new ArrayList<>();

    public WordDocument() {
        System.out.print("WordDocument构造器");
    }

    public String getmText() {
        return mText;
    }

    public void setmText(String mText) {
        this.mText = mText;
    }

    public ArrayList<String> getImages() {
        return images;
    }

    public void addImages(String image) {
        this.images.add(image);
    }

    @Override
    public WordDocument clone() {

        try {
            WordDocument wordDocument = (WordDocument) super.clone();
            wordDocument.mText = this.mText;
            wordDocument.images = (ArrayList<String>) this.images.clone();
            return wordDocument;
        } catch (Exception e) {
            e.printStackTrace();
        }

        return null;
    }

    public void showWordDocument() {
        System.out.println("<<<<<<<<<<<<<<<WordDocument Start>>>>>>>>>>>>>");
        System.out.println("Text:" + mText);
        System.out.println("Images List");
        for (String image: images) {
            System.out.println(image);
        }
        System.out.println("<<<<<<<<<<<<<<<WordDocument End>>>>>>>>>>>>>");
        System.out.println();
    }
}
